package com.qfedu.knowledge.entity.dto;

import com.qfedu.knowledge.iterator.Aggregate;
import com.qfedu.knowledge.iterator.Iterator;
import lombok.Data;

import java.util.List;

/**
 * @ClassName DictDTO
 * @Author ykx
 * @Date 2024/5/9 16:04
 * @Version 1.0
 */
@Data
public class DictDTO implements Aggregate {
    /**
     * 字典项
     */
    private String itemCode;

    /**
     * 字典值列表
     */
    private List<String> valueCodeList;

    /**
     * 字典名列表
     */
    private List<String> valueNameList;

    @Override
    public Iterator createIterator() {
        return new CodeListIterator();
    }

    private class CodeListIterator implements Iterator {

        private int index = 0;

        @Override
        public boolean hasNext() {
            return index < valueCodeList.size();
        }

        @Override
        public Object next() {
            return valueCodeList.get(index++);
        }
    }

}
